package com.PinZhuo.www.shouye;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.PinZhuo.www.R;
import com.me.maxwin.view.XListView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tukela on 2015/10/12.
 */
public class FragmentPinZhuoList extends Fragment implements XListView.IXListViewListener {
    private View rootView;
    private XListView listView;
    public List<PinZhuo> list=new ArrayList<>();
    private Activity activity;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        rootView=inflater.inflate(R.layout.fragment_home_shangjia,null);
        listView= (XListView) rootView.findViewById(R.id.listview);
        listView.setXListViewListener(this);
        listView.setPullRefreshEnable(true);
        listView.setPullLoadEnable(true);
        listView.setAdapter(new MyAdapter());



        return  rootView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        list.add(new PinZhuo());
        list.add(new PinZhuo());
        list.add(new PinZhuo());
        list.add(new PinZhuo());
        list.add(new PinZhuo());
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        this.activity=activity;
    }

    @Override
    public void onRefresh() {

    }

    @Override
    public void onLoadMore() {

    }

    class MyAdapter extends BaseAdapter{
        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView==null)
            {
                convertView=LayoutInflater.from(activity).inflate(R.layout.fragment_home_pinzhuo_item,null);
            }



            return convertView;
        }
    }

}

